59

Explore Your Deductive Logic—Sudoku

59

STEP 19 continued

    For j =​ 1 To 9

      If putnumberpresent(1, j) <> “*” And sbox(i, j) =​ ““ And putnumberpresent(i, j)

<> ““ Then

        nodecount =​ nodecount +​ 1

       

        PRowFound =​ 0

        For k =​ 1 To 9

          If PRow(k) <> ““ Then

            If PRow(k) =​ Left(putnumberpresent(i, j), 1) Then

              PRowFound =​ 1

              Exit For

            End If

          End If

        Next k

        If PRowFound =​ 0 Then

            RowCount =​ RowCount +​ 1

            PRow(RowCount) =​ Left(putnumberpresent(i, j), 1)

        End If

       

        PRowFound =​ 0

        For k =​ 1 To 9

          If PRow(k) <> ““ Then

            If PRow(k) =​ Right(putnumberpresent(i, j), 1) Then

              PRowFound =​ 1

              Exit For

          End If

        End If

      Next k

      If PRowFound =​ 0 Then

          RowCount =​ RowCount +​ 1

          PRow(RowCount) =​ Right(putnumberpresent(i, j), 1)

      End If

    End If

Next j

Next i

:

STEP 20

The third and final step is to first determine if this is a polyomino by comparing

the rowcount with the nodecount as discussed earlier, and then if so, adding the

putnumber to the cantbelist of the appropriate cells.

:

:

If nodecount =​ 2 * RowCount Then

‘ this check proves that this is a polyomino

    For i =​ 1 To 9

      For j =​ 1 To 9

        PRowFound =​ 0

        PColFound =​ 0

        For k =​ 1 To 9